package com.boot.web.controller;

import java.util.Map;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.boot.communal.paging.InitPaging;
import com.boot.communal.response.ResponseServer;
import com.boot.web.entity.ChinaAreas;
import com.boot.web.service.ChinaAreasService;

/**
 * 收费地区控制器
 * @author 【zhouJie】
 * @date 2021-09-30 15:29:32
 */
@RestController
@RequestMapping("/chinaAreas")
public class ChinaAreasController {

    @Autowired
    private ChinaAreasService chinaAreasService;

    @PostMapping("/save")
    public ResponseServer save(ChinaAreas chinaAreas) {
        return ResponseServer.success("添加成功", chinaAreasService.save(chinaAreas));
    }

    @PutMapping("/update")
    public ResponseServer update(ChinaAreas chinaAreas) {
        return ResponseServer.success("修改成功", chinaAreasService.update(chinaAreas));
    }

    @DeleteMapping("/delete/{id}")
    public ResponseServer delete(@PathVariable Integer id) {
        return ResponseServer.success("删除成功", chinaAreasService.delete(id));
    }

    @DeleteMapping("/batchDelete/{ids}")
    public ResponseServer batchDelete(@PathVariable Integer[] ids) {
        return ResponseServer.success("批量删除成功", chinaAreasService.batchDelete(ids));
    }

    @GetMapping("/getPageList")
    public ResponseServer getPageList(@RequestParam Map<String, Object> params) {
        InitPaging.init(params);
        return ResponseServer.success(new PageInfo(chinaAreasService.getPageList(params)));
    }

    @GetMapping("/getAll")
    public ResponseServer getAll() {
        return ResponseServer.success(chinaAreasService.getAll());
    }

    @GetMapping("/getById/{id}")
    public ResponseServer getById(@PathVariable Integer id) {
        return ResponseServer.success(chinaAreasService.getById(id));
    }

}
